package org.easy.eao.utils;

import java.lang.annotation.Annotation;
import java.util.HashMap;
import java.util.Map;

public class Parameter {

	private int index;
	private Class<?> type;
	private Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();

	public Parameter(int index, Class<?> type, Annotation[] annotations) {
		this.index = index;
		this.type = type;
		for (Annotation a : annotations) {
			this.annotations.put(a.annotationType(), a);
		}
	}

	public int getIndex() {
		return index;
	}

	public Class<?> getType() {
		return type;
	}

	@SuppressWarnings("unchecked")
	public <T> T getAnnotation(Class<T> clz) {
		return (T) annotations.get(clz);
	}

	public boolean hasAnnotation(Class<? extends Annotation> clz) {
		return annotations.containsKey(clz);
	}
}
